// src/services/OnlineTranslator.ts
import { type Translator,type  TranslationResponse } from './Translator';

export class StarDictTranslator implements Translator {
  valid(): boolean {
    return true;
  }
  getName(): string {
    return "ECDICT词典数据"
  }
  async translate(text: string, _: string): Promise<TranslationResponse> {
    const response = await fetch('http://127.0.0.1:5000/definition?word='+text);
    const data = await response.json();
    console.log("translate res:",data)
    return {
      translation: data.translation,
    };
  }
}